package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.GoodStyle;
import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.mapper.GoodStyleMapper;
import cn.wolfcode.trip.base.mapper.StrategyMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IGoodStyleService;
import cn.wolfcode.trip.base.service.IStrategyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodStyleServiceImpl implements IGoodStyleService {
    @Autowired
    private GoodStyleMapper goodStyleMapper;

    public PageInfo<GoodStyle> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<GoodStyle> list = goodStyleMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    public void saveOrUpdate(GoodStyle entity) {
        if (entity.getId() == null) {
            goodStyleMapper.insert(entity);
        } else {
            goodStyleMapper.updateByPrimaryKey(entity);
        }
    }

    public List<GoodStyle> list() {
        return goodStyleMapper.selectEnable();
    }

    public GoodStyle get(Long id) {
        return goodStyleMapper.selectByPrimaryKey(id);
    }
}
